<?php

/**
 * Some rights reserved：abc3210.com
 * Contact email:admin@abc3210.com
 */
class CategoryModel extends CommonModel {

    //array(验证字段,验证规则,错误提示,[验证条件,附加规则,验证时间])
    protected $_validate = array(
    );
    //array(填充字段,填充内容,[填充条件,附加规则])
    protected $_auto = array(
    );

    /*
     * 生成缓存，以栏目ID为数组下标，以排序字段listorder ASC排序
     */

    public function CategoryCache() {
        $models = F("Model");
        $data = $this->order("listorder ASC")->select();
        $categorys = array();
        foreach ($data as $r) {
            unset($r['module']);
            $setting = unserialize($r['setting']);
            $r['create_to_html_root'] = $setting['create_to_html_root'];
            $r['ishtml'] = $setting['ishtml'];
            $r['content_ishtml'] = $setting['content_ishtml'];
            $r['category_ruleid'] = $setting['category_ruleid'];
            $r['show_ruleid'] = $setting['show_ruleid'];
            $r['workflowid'] = $setting['workflowid'];
            $r['isdomain'] = '0';
            if (!preg_match('/^(http|https):\/\//', $r['url'])) {
                 //本站域名后面不能带/
                $Domain = urlDomain(CONFIG_SITEURL);
                if ($Domain) {
                    $r['url'] = substr($Domain,0,-1) . $r['url'];
                } 
            } elseif ($r['ishtml']) {
                $r['isdomain'] = '1';
            }
            $categorys[$r['catid']] = $r;
        }
        F("Category", $categorys);
        unset($data);
        unset($models);
        unset($array);
        return true;
    }

}

?>
